﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


using FXnaWpfBase;

using System.Windows.Controls;

using FXnaGis;



namespace FXnaAppBaseWpf
{

    public class VectorImageVM:MDTVIViewModel
    {

        public VectorImageVM(MDTVIViewModel parent,FGroupLayer group)
            : base(parent)
        {
            this._vectorGroup = group;


            this._vectorGroup.LayerAdded += new EventHandler<LayerEventArgs>(_vectorGroup_LayerAdded);
            this._vectorGroup.LayerRemoved += new EventHandler<LayerEventArgs>(_vectorGroup_LayerRemoved);


            this.LoadChildren ();
 
        }


        public override string Desc
        {
            get
            {
                return this._vectorGroup.Desc;
            }

        }


        void _vectorGroup_LayerRemoved(object sender, LayerEventArgs e)
        {

            this.Children.Clear();

            this.LoadChildren();

        }



        void _vectorGroup_LayerAdded(object sender, LayerEventArgs e)
        {
          
        }


        FGroupLayer _vectorGroup;

        public FGroupLayer VectorGroup
        {
            get { return _vectorGroup; }
            set { _vectorGroup = value; }
        }



        protected override void LoadChildren()
        {
            foreach (FLayer item in this._vectorGroup.Children)
            {
                if (item is FVectorLayer)
                {
                    FVectorLayer vlayer = item as FVectorLayer;

                    VectorImageLayerVM vil = new VectorImageLayerVM(this,vlayer);

                    this.Children.Add(vil);



                    
                }

                
            }
            
        }


    }
}
